package com.e3.sysmg.config.client;

import java.util.List;

import com.e3.sysmg.config.model.ParameterModel;
import com.e3.sysmg.config.model.ParameterQC;
import com.e3.template.tgf.TGFQueryDialog;
import com.e3.web.core.client.GwtAsyncCallback;
import com.e3.web.core.model.SuperQC;
import com.extjs.gxt.ui.client.widget.form.Field;

public class ParameterQueryDialog extends TGFQueryDialog<ParameterModel> {
	
	private ParameterRPCServiceAsync service = ParameterRPCService.Util.getInstance();

	@Override
	protected SuperQC getQueryCondition() {
		String name = (String)getMyFormField(ParameterModel.NAME).getFieldValue();
		Integer type = (Integer)getMyFormField(ParameterModel.TYPE).getFieldValue();
		Integer level = (Integer)getMyFormField(ParameterModel.LEVEL).getFieldValue();
		String value = (String)getMyFormField(ParameterModel.VALUE).getFieldValue();
		
		ParameterQC qc = new ParameterQC();
		qc.setName(name);
		qc.setType(type);
		qc.setLevel(level);
		qc.setValue(value);
		return qc;
	}

	@Override
	protected List<Field<?>> getFormFields() {
		String[] fNames = {ParameterModel.NAME,ParameterModel.TYPE,ParameterModel.LEVEL,ParameterModel.VALUE};
		return ParameterHelper.INSTANCE.getFormFields(fNames);
	}

	@Override
	protected void executeQueryService(SuperQC qc,GwtAsyncCallback<List<ParameterModel>> callback) {
		service.getParameterByCondition((ParameterQC)qc, callback);
	}

}
